package cn.tx.util;

import cn.tx.dao.ClazzDao;
import cn.tx.dao.ManagerDao;
import cn.tx.dao.GradeDao;
import cn.tx.model.Clazz;
import cn.tx.model.Manager;

import cn.tx.model.Grade;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


@RunWith(SpringJUnit4ClassRunner.class)// 添加spring测试方案
@ContextConfiguration("/config/spring/applicationContext.xml")// 指定spring配置文件位置
public class MyBatisTest {

    @Autowired
    private ManagerDao managerDao;

    //
    @Test
    public void testInsert() {
        Manager c = new Manager();
        c.setName("2022");
        c.setPassword("测试组");
        managerDao.addManager(c);
    }
    @Test
    public void testUpdate() {
        Manager c = new Manager();
        c.setId(5);
        c.setName("2022-修改");
        c.setPassword("测试组程序修改");
        managerDao.UpdateManagerById(c);

    }
    @Test
    public void testDelete() {
        managerDao.delete("27");
    }
    @Test
    public void testSelect() {
        List<Manager> list =  managerDao.findAll();
        for(Manager c:list){
            System.out.println(c.getId()+"---"+c.getName());
        }
    }
    @Test
    public void testFind() {
        Map<String, Object> querymap = new HashMap<String, Object>();
        querymap.put("name", "%张三%");
        querymap.put("offset", 0);
        querymap.put("pageSize", 10);
        List<Manager> list = managerDao.findList(querymap);
        for (Manager c : list) {
            System.out.println(c.getId() + "---" + c.getName());
        }

    }
}
